<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>沈阳国安驾校</title>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta charset="utf-8">
<link href="${ctx}/static/weixin/hotels.css" rel="stylesheet"
	type="text/css">
<script src="${ctx}/static/weixin/jquery.min.js" type="text/javascript"></script>
<style>
.list li .text {
	height: 20px;
	word-break: break-all;
	display: table-row;
}

.list li .text .f-left {
	float: left;
}

.list li .text .f-right {
	float: right;
}


.rbu {
	background-color: #179F00;
	padding: 5px 10px;
	margin: 10px 4px;
	font-size: 13px;
	border: 1px solid #0B8E00;
	background-image: linear-gradient(bottom, #179F00 0%, #5DD300 100%);
	background-image: -o-linear-gradient(bottom, #179F00 0%, #5DD300 100%);
	background-image: -moz-linear-gradient(bottom, #179F00 0%, #5DD300 100%);
	background-image: -webkit-linear-gradient(bottom, #179F00 0%, #5DD300 100%);
	background-image: -ms-linear-gradient(bottom, #179F00 0%, #5DD300 100%);
	background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #179F00),
		color-stop(1, #5DD300));
	-webkit-box-shadow: 0 1px 0 #94E700 inset, 0 1px 2px rgba(0, 0, 0, 0.5);
	-moz-box-shadow: 0 1px 0 #94E700 inset, 0 1px 2px rgba(0, 0, 0, 0.5);
	box-shadow: 0 1px 0 #94E700 inset, 0 1px 2px rgba(0, 0, 0, 0.5);
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	-o-border-radius: 5px;
	border-radius: 5px;
	color: #ffffff;
	display: block;
	text-align: center;
	text-shadow: 0 1px rgba(0, 0, 0, 0.2);
	display: table-column;
	font-size: 13px;
}
</style>
</head>

<body>
	<div class="cardexplain">
		<jsp:include page="${ctx}/weixin/coach/coachConfig" />
		<div class="footReturn" style="text-align: center">
			<input type="button" style="margin: 0 auto 20px auto; width: 90%"
				class="submit" value="返回"
				onclick="window.location='${ctx}/weixin/coach/index_${userType}'">
		</div>
		<c:if test="${userType == 2}">
			<div class="footReturn" style="text-align: center">
				<input type="button" style="margin: 0 auto 20px auto; width: 90%"
					class="submit" value="学员绑定码"
					onclick="window.location='${ctx}/weixin/randomKey/index?type=${type}'">
			</div>

			<ul class="round list">
				<li class="title mb"><span class="none">预约练车信息</span></li>
				<c:forEach var="coach" items="${coachLists}" varStatus="status">
					<li>
						<div class="text">
							<div class="f-left">
								日期：
								<joda:format value="${coach.coachTime}" pattern="yyyy-MM-dd" />
							</div>
							<div class="f-right">已预约: ${coach.isyy}</div>
						</div>
						<div class="text">
							<button class="rbu"
								onclick="window.location='${ctx}/weixin/coach/update?coachId=${coach.id}'">修改练车计划</button>
							<button class="rbu"
								onclick="window.location='${ctx}/weixin/coach/itemShow?coachId=${coach.id}'">查看学员预约</button>
							<button class="rbu"
								onclick="if(confirm('是否要${ coach.status == 1?'取消':'开启'}[<joda:format value="${coach.coachTime}" pattern="yyyy-MM-dd" />]的练车计划],取消计划将清楚该计划下所有的学员预约')){window.location='${ctx}/weixin/coach/cleanCoach?coachId=${coach.id}'}">
								${ coach.status == 1?'取消':'开启'}计划</button>
						</div>
					</li>
				</c:forEach>
			</ul>
		</c:if>
		<c:if test="${userType == 1}">
			<ul class="round list">
				<li class="title mb"><span class="none">预约练车信息</span></li>
				<c:forEach var="coach" items="${coachLists}" varStatus="status">

					<li><div class="text" style="height: 40px; display: block;">
							<div class="f-left" style="height: 40px; line-height: 40px;">
								日期：
								<joda:format value="${coach.coachTime}" pattern="yyyy-MM-dd" />
							</div>
							<div class="f-right" style="height: 40px; line-height: 40px;">
								<c:if test="${coach.isyy >0 }">
								     已预约
								    </c:if>
								<c:if test="${coach.isyy == 0 }">
									<c:if test="${coach.status == 1 }">
										<c:if test="${coach.ism == 1 }">
									              预约已满，不可预约 
									    </c:if>
										<c:if test="${coach.ism == 0 }">
											<c:if test="${status.index == 2 }">
												<div id="yy"></div>
												<script>
												var coachId = ${coach.id};
											
												$(function($){
													var st  = null;
													function chanageYY(){
														var myDate = new Date();
														var hh = myDate.getHours(); 
														if(hh<12){
															$('#yy').html('12点开启预约');
														}else{
															$('#yy').html('<button class="rbu"	onclick="window.location=\'${ctx }/weixin/coach/item?coachId='+coachId+'\'">开始预约</button>');
															if(st!=null)
															clearInterval(st);
														}
													}
													st = setInterval(chanageYY,1000);
													chanageYY();
													
												});
											   </script>
											</c:if>
											<c:if test="${status.index != 2 }">
												<button  class="rbu"
													onclick="window.location='${ctx }/weixin/coach/item?coachId=${coach.id}'">开始预约</button>
											</c:if>
										</c:if>
									</c:if>
									<c:if test="${coach.status == 0 }">
									        预约已关闭，不可预约
									</c:if>
								</c:if>

							</div>
						</div></li>
				</c:forEach>
			</ul>
			<div class="footReturn" style="text-align: center">
				<input type="button" style="margin: 0 auto 20px auto; width: 90%"
					class="submit" value="我的预约"
					onclick="window.location='${ctx}/weixin/student/userCoach'">
			</div>
		</c:if>
	</div>
</body>
</html>